/**
 *
 *
 *
 */


function mergeTwoArr(A, B) {
    if (!A.length && !B.length) return null;

    if (!A.length) return B
    if (!B.length) return A


    A.sort((a, b) => a - b)
    B.sort((a, b) => a - b)

    let temp = []
    for (let i = 0; i < A.length; ) {
        for (let j = 0; j < B.length; ) {
            if (A[i] < B[j]) {
                temp.push(A[i])
                i++
            } else {
                temp.push(B[j])
                j++
            }
        }
    }
    return temp;
}

console.log(mergeTwoArr([1, 2, 3], [2, 3, 4, 5, 6]));

